/*mask bec*/
var at_mask = {
    mask_bg : null,
    mask_id : "#js_ui_mask_v2",
    overlayOpacity : 0,
    shuticon : ".shut_icon",
    callback:null,
	openCallback:null,
	//是否强制在屏幕居中
	needFix:true,
	//如果不强制,则指定对视口的高度
	usTop:0,
	_offsetX:0,
    showMask : function() {
        var $_maskbg = $(this.mask_bg);
        var pos = ($.browser.msie && parseInt($.browser.version) <= 6) ? 'absolute'
        : 'fixed';
        var that = this;
        if($(".at_mask_bg").size()==0) {
            $_maskbg = $(document.createElement("div"));
            this.mask_bg = $_maskbg;
            $_maskbg.css({
                position : "absolute",
                height : $(document).height()
            });
            $_maskbg.addClass("at_mask_bg");
            $_maskbg.appendTo($("body")[0]);
        }
        this.getPosition();
        if(typeof(that.openCallback)=='function'){
        	that.openCallback();
        }
        $(this.mask_id).find(this.shuticon).live("click",function() {
            that.removeBg();
            return false;
        });
        $(document).bind("keyup", function(e) {
            if (e.keyCode == 27) {
                that.removeBg();
            }
        });
        
            $(window).bind("resize",function(e){
                if($(at_mask.mask_id).css("display")!="none"){
                   that.getPosition();
                }
            });
        
        $(window).bind("scroll",function(e){
            $_maskbg.css("height",$(document).height());
        });
        $("li[rel='act_enter']").bind("keypress", function(e) {
            if (e.keyCode == 13) {
                act_login();
            }
        });
    },
    getPosition: function() {
        var pos = ($.browser.msie && parseInt($.browser.version) <= 6) ? 'absolute' : 'fixed';
        $(this.mask_id).show();
        if(this.needFix){
            if($.browser.msie && parseInt($.browser.version) <= 6) {
                var mask_t =(document.documentElement.scrollTop + (document.documentElement.clientHeight - $(this.mask_id)[0].offsetHeight) / 2)+"px";
            } else {
                var mask_t=((document.documentElement.clientHeight - $(this.mask_id)[0].offsetHeight) / 2)+"px";
            }
            var mask_l = (document.documentElement.scrollLeft + (document.documentElement.clientWidth - $(this.mask_id)[0].offsetWidth) / 2)+"px";
        }else{
            //手工给它加上对顶的高度
             //document.documentElement.scrollTop=0;
             var mask_t =this.usTop+"px";
             var mask_l = (document.documentElement.scrollLeft + (document.documentElement.clientWidth - $(this.mask_id)[0].offsetWidth) / 2)+this._offsetX+"px";
        }
        
        if(this.needFix){
            $(this.mask_id).css({
                top : mask_t,
                left : mask_l,
                position:pos
            });
        }else{
            $(this.mask_id).css({
                top : mask_t,
                left : mask_l,
                position:"absolute"
            });
        }
    },
    removeBg : function() {
        var that = this;
        if($(".at_mask_bg").length>0) {
            that.mask_bg.fadeOut("fast", function() {
                that.mask_bg.remove();
                $(".at_mask_bg").remove();
            });
        }
        $(that.mask_id).hide();
        if(that.callback!=null&&typeof(that.callback)=='function') {
            that.callback();
        }
    }
};